﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChargeManagement.DAL;
using System.Data;
using System.Reflection;

namespace ChargeManagement.BLL
{
    public class CashFacade
    {
        const string ASSEMBLY_NAME = "ChargeManagement.BLL";      

        //得到现金收取类型列表，返回字符串数组
        public string[] GetCashAcceptTypeList()
        {
            //string c = SDFL.Helper.DllConfigHelper.ConnectionString();
            return CashAcceptType.GetCashAcceptTypeList();
        }

        /**/
        /// <summary>
        /// 用于根据商品活动的不同和原价格，计算此商品的实际收费
        /// </summary>
        /// <param name="selectValue">下拉列表选择的折价类型</param>
        /// <param name="startTotal">原价</param>
        /// <returns>实际价格</returns>
        public double GetFactTotal(string selectValue, double startTotal)
        {            
            CashContext cc = new CashContext();           

            cc.setBehavior((CashBase)Assembly.Load(ASSEMBLY_NAME).CreateInstance(
                ASSEMBLY_NAME + "." + CashAcceptType.GetAlgorithmClass(selectValue), 
                false, 
                BindingFlags.Default, 
                null,
                CashAcceptType.GetAlgorithmArgs(selectValue),
                null, 
                null));

            return cc.GetResult(startTotal);
        }        
    }
}
